<template>
  <div>
    <SelfAdaption slot="adaption-bar">
      <Form :model="searchForm" ref="formSearch" slot="adaption-bar" class="ivu-form-no-margin-bottom" inline>
        <!-- 更换业务单元获取方式 -->
        <FormItem v-for="(item, index) in searchOptions" :key="index" :prop="item.key" :label="item.text">
          <Select v-if="item.type === 'select'" :clearable="item.clearable || false" v-model="searchForm[item.key]" @on-change="val => (item.onChange ? item.onChange(val) : null)">
            <Option v-for="item2 in item.options" :value="item2.value" :key="item2.value">{{ item2.text }}</Option>
          </Select>

          <DatePicker
            v-else-if="item.type === 'date'"
            :type="item.dateType || 'date'"
            v-model="searchForm[item.key]"
            :placeholder="item.placeholder"
            :clearable="item.clearable || false"
            @on-change="val => (item.onChange ? item.onChange(val) : null)"
          />

          <iInput v-else type="text" v-model="searchForm[item.key]" :placeholder="item.placeholder"></iInput>
        </FormItem>
        <!--  查询 -->
        <Form-item prop="button" class="search-solt-btn">
          <RPButton optType="search" @click="searchValueSet" />
        </Form-item>
      </Form>
    </SelfAdaption>
    <InnerPageTable ref="coverTable" :config="pageTableConfig" v-if="loadInit">
      <div slot="table-bar" v-if="fromPage == 'creater'">
        <RPButton v-if="type !== 'rate'" :disabled="importDisabled" optType="create" type="info" @click="showImport" text="导入" />
        <RPButton optType="create" type="info" text="删除" @click="batchDel"/>
      </div>
    </InnerPageTable>
    <Modal
        v-model="importDisplay"
        title="导入"
        :loading='importLoadding'
        @on-ok="handleImportFun"
        @on-cancel="importDisplay = false">
        <Form :model="importForm" ref="importForm" :rules='importRules'>
          <FormItem v-for="(item, index) in importOptions" :key="index" :prop="item.key" :label="item.text" :label-width="110">
            <Select v-model="importForm[item.key]" @on-change="val => (item.onChange ? item.onChange(val) : null)">
              <Option v-for="item2 in item.options" :value="item2.value" :key="item2.value">{{ item2.text }}</Option>
            </Select>
          </FormItem>
          <FormItem prop="file" label='上传附件：' :label-width="110">
            <Upload
              :before-upload="handleUpload"
              accept=".xls,.xlsx"
              action="//"
              :max-size="10240">
              <Button icon="ios-cloud-upload-outline">上传文件</Button>
              <p>{{ importForm.file }}</p>
            </Upload>
            <p style="color: #c5c8ce;">请上传.xls .xlsx格式的文件</p>
          </FormItem>
        </Form>
    </Modal>
    <Modal
        class="modify-modal"
        v-model="modifyDisplay"
        title="导入"
        :loading='modifyLoadding'
        @on-ok="handleModifyFun"
        @on-cancel="modifyDisplay = false">
        <Form :model="modifyForm" ref="modifyForm" :rules='importRules'>
          <FormItem v-for="(item, index) in importOptions" :key="index" :prop="item.key" :label="item.text" :label-width="110">
            <Select v-model="modifyForm[item.key]" @on-change="val => (item.onChange ? item.onChange(val) : null)" disabled>
              <Option v-for="item2 in item.options" :value="item2.value" :key="item2.value">{{ item2.text }}</Option>
            </Select>
          </FormItem>
          <FormItem prop="file" label='上传附件：' :label-width="110">
            <Upload
              :before-upload="handleModifyUpload"
              accept=".xls,.xlsx"
              action="//"
              :max-size="10240">
              <Button icon="ios-cloud-upload-outline">上传文件</Button>
              <p>{{ modifyForm.file }}</p>
            </Upload>
            <Button class="download-btn" type="text" @click="exportFun(modifyForm.row)">下载模板</Button>
            <p style="color: #c5c8ce;">请上传.xls .xlsx格式的文件</p>
          </FormItem>
        </Form>
    </Modal>
  </div>
</template>

<script>
import { GetLists2 } from './columns.js'
import { GetCalLists2 } from './columnsCal.js'
// import uploadFile from '../uploadFile/index.vue'
import CoverRateEdit from './CoverRateEdit.vue'
import CoverTargetEdit from './CoverTargetEdit.vue'
import coverApi from '@/api/cover.js'
import sysConfigApi from '@/api/sysConfig.js'
import coverData from '@/api/data.js'
import revisionRecord from '../common/revisionRecord.vue'
// import downLoadFile from '../common/downLoadFile.vue'
import { excludeHiddenBussinessUnit } from '@/tools/common.js'
import { approvalMix } from '@/views/todoCenter/myApproval/approval-mix'
import { PROCESS_STATUS_LIST, PROCESS_STATUS_MAP } from '@/tools/common.js'
import { ALL_DATA_FLAG_LIST, ALL_DATA_FLAG_NEW } from '@/views/dataSummary/const.js'
import coverDetail from './coverDetail.vue'
export default {
  name: 'cover',
  components: {
    // uploadFile
  },
  mixins: [approvalMix],
  props: {
    type: {
      type: String,
      default: 'rate'
    },
    title: {
      type: String,
      default: ''
    },
    showAdd: {
      type: Boolean,
      default: true
    },
    uploadUrl: {
      type: String,
      default: 'rate'
    },
    downloadUrl: {
      type: String,
      default: 'rate'
    },
    vsCode: {
      type: String,
      default: ''
    },
    pageType: {
      type: String,
      default: ''
    },
    fromPage: {
      type: String,
      default: 'creater'
    },
    bussinessCode: {
       type: String,
      default: ''
    },
    '$route': {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      writePermission: true,
      modifyDisplay: false,
      modifyLoadding: true,
      importDisplay: false,
      importLoadding: true,
      importForm: {
        trgNode: '',
        reportCycle: '',
        file: ''
      },
      modifyForm: {
        row: undefined,
        trgNode: '',
        reportCycle: '',
        file: ''
      },
      processStatusList: PROCESS_STATUS_LIST,
      loadInit: false,
      useApiGetData: true,
      logTypeList: {
        creater: {
          rate: 8,
          target: 7,
          status: 6,
        },
        Summary: {
          rate: 4,
          target: 3,
          status: 2,
        }
      },
      select: '',
      searchForm: {
        id: '',
        trgNode: '',
        company: '',
        operateStatus: '',
        vsCode: this.vsCode,
        vsiDescription: '',
        fromPage: this.fromPage,
        allDataFlag: ALL_DATA_FLAG_NEW,
        reportCycle: '',
        self: this
      },
      bussinessUnit: [],
      secondOrgan: [],
      ids:[],
      pageTableConfig: {
        initParam: { allDataFlag: ALL_DATA_FLAG_NEW },
        loadDataFn: this.getListPage,
        columns: this.type == 'target' ?  GetLists2.bind(this)() : GetCalLists2.bind(this)(),
        autoFirst: false,
        onSelectionChange: this.onSelectionChange
      }
    }
  },
  mounted() {
      this.$nextTick(() => {
        this.init()
      })
  },
  computed: {
    menuNo() {
      let menuNo = ''
      // 2022年数字化覆盖现状
      if (this.type == 'status') {
        menuNo = this.fromPage == 'creater' ? 'status' : 'summary-status'
      // “十四五”数字化覆盖目标
      } else if (this.type == 'target') {
        menuNo = this.fromPage == 'creater' ? 'target' : 'summary-target'
      // 数字化覆盖率计算表
      } else if (this.type == 'rate') {
        menuNo = this.fromPage == 'creater' ? 'rate' : 'summary-rate'
      }
      return menuNo
    },
    importOptions() {
      const trgNodes = this.bussinessUnit.map(item => {
        return {
          text: item.trgNode || item.vsiValue,
          value: item.trgNode || item.vsiValue
        }
      })
      let list = [
        {
          text: '业务单元：',
          type: 'select',
          key: 'trgNode',
          options: trgNodes
        },
      ]
      // 数字化覆盖现状表 数字化覆盖率计算表 
      if (this.type == 'status' || this.type == 'rate') {
        list.splice(1, 0, ...[
          {
            text: '填报周期：',
            type: 'select',
            key: 'reportCycle',
            options:[
              {text: '2021-H1', value: '2021-H1'},
              {text: '2021-H2', value: '2021-H2'},
              {text: '2022-H1', value: '2022-H1'},
              {text: '2022-H2', value: '2022-H2'},
              {text: '2023-H1', value: '2023-H1'},
              {text: '2023-H2', value: '2023-H2'},
              {text: '2024-H1', value: '2024-H1'},
              {text: '2024-H2', value: '2024-H2'},
              {text: '2025-H1', value: '2025-H1'},
              {text: '2025-H2', value: '2025-H2'}
            ]
          }
        ])
      // “十四五”数字化覆盖目标
      } else if (this.type == 'target') {
        list.splice(1, 0, ...[
          {
            text: '目标年度：',
            type: 'select',
            key: 'reportCycle',
            options: [
              {text: '2021', value: '2021'},
              {text: '2022', value: '2022'},
              {text: '2023', value: '2023'},
              {text: '2024', value: '2024'},
              {text: '2025', value: '2025'}
            ]
          },
        ])
      }
      return list
    },
    searchOptions() {
      const trgNodes = this.bussinessUnit.map(item => {
          return {
            text: item.trgNode || item.vsiValue,
            value: item.trgNode || item.vsiValue
          }
        })
      let list = [
        {
          text: '业务单元：',
          type: 'select',
          key: 'trgNode',
          options: trgNodes,
          clearable: true,
          onChange: this.changetrgNode
        },
        {
          text: '数值范围：',
          type: 'select',
          key: 'allDataFlag',
          options: ALL_DATA_FLAG_LIST
        },
      ]
      if (this.type == 'status' || this.type == 'rate') {
        list.splice(1, 0, ...[
          {
            text: '填报周期：',
            type: 'select',
            key: 'reportCycle',
            clearable: true,
            options:[
              {text: '2021-H1', value: '2021-H1'},
              {text: '2021-H2', value: '2021-H2'},
              {text: '2022-H1', value: '2022-H1'},
              {text: '2022-H2', value: '2022-H2'},
              {text: '2023-H1', value: '2023-H1'},
              {text: '2023-H2', value: '2023-H2'},
              {text: '2024-H1', value: '2024-H1'},
              {text: '2024-H2', value: '2024-H2'},
              {text: '2025-H1', value: '2025-H1'},
              {text: '2025-H2', value: '2025-H2'}
            ]
          },
          {
            text: '审核状态：',
            type: 'select',
            key: 'operateStatus',
            clearable: true,
            options: PROCESS_STATUS_LIST
          },
        ])
      // “十四五”数字化覆盖目标
      } else if (this.type == 'target') {
        list.splice(1, 0, ...[
          {
            text: '目标年度：',
            type: 'select',
            key: 'reportCycle',
            clearable: true,
            options: [
              {text: '2021', value: '2021'},
              {text: '2022', value: '2022'},
              {text: '2023', value: '2023'},
              {text: '2024', value: '2024'},
              {text: '2025', value: '2025'}
            ]
          },
        ])
      }
      return list
    },
    rptType() {
      if (this.type === 'target') {
        return '3'
      // 数字化覆盖率计算表
      } else if (this.type === 'rate') {
        return '4'
      }
      return '2'
    },
    importRules() {
      const fileDataValidator =  (rule, value, callback) => {
        let fileData = this.importForm.fileData
        if (this.modifyDisplay) {
          fileData = this.modifyForm.fileData
        }
        if (fileData === undefined || fileData === null) {
          callback(new Error('请选择上传文件'))
        } else if(fileData.size > 10 * 1024 * 1024) {
          //限制10M
          callback(new Error('文件大小限制为10M，请重试'))
        } else {
          callback()
        }
      }
      
      if (this.type === 'target') {
        return {
          trgNode: [{required: true, message: "请选择业务单元", trigger: "change"}],
          reportCycle: [{required: true, message: "请选择目标年度", trigger: "change"}],
          file: [{required: true, validator: fileDataValidator.bind(this), trigger: "change"}]
        }  
      }
      return {
        trgNode: [{required: true, message: "请选择业务单元", trigger: "change"}],
        reportCycle: [{required: true, message: "请选择填报周期", trigger: "change"}],
        file: [{required: true, validator: fileDataValidator.bind(this), trigger: "change"}]
      }
    },
    importDisabled() {
      if (this.writePermission === false && (this.type == 'status' || this.type == 'rate')) {
        return true
      } else {
        return false
      }
    },
  },
  methods: {
    url(type, pathname) {
      return window.RPConfig[type] + pathname;
    },
    revisionRecord(row) {
      new this.$pageModal(
        revisionRecord,
        {
          props: {
            recordId: row.id
          }
        },
      );
    },
    exportFun(row) {
      coverApi.downloadFile3(row.id)
      // coverApi.downLoadFun({url: this.url('itShare', `/rptDgcalOperate/listExport/common?operateId=${row.id}`)})
    },
    deleteFun(params) {
      let ids = []
      if (Array.isArray(params)) {
        ids = [...params]
      } else if (params.id) {
        ids.push(params.id)
      }
       this.$confirm({
          title:"删除",
          content: "当前表删除后不可撤回，您是否要继续删除?"
        }).then(()=>{
          coverApi.coverDelete2({
            type: this.fromPage,
            data: ids
          }).then((result) => {
            if(result.data.code == 200){
              this.$Message.success({
                content: '删除成功',
                duration: 3
            })
          } else {
            this.$Message.error({
              content: result.data.msg || '删除失败',
              duration: 3
              })
            }
            this.searchValueSet()
          })
        })

      //删除
    },
    getConfig() {
      sysConfigApi.getCurrentConfig({ reportName: "关键业务环节数字化覆盖度" }).then(res => {
        const data = res.data.data
        if (data) {
          this.writePermission = data.writePermission === false ? false : true
        }
      })
    },
    //获取业务单元
    init() {
      this.getConfig()
      if (this.useApiGetData) {
           // 更换业务单元获取方式
        coverApi.getRptReportTrgnodePList({reportName: "关键业务环节数字化覆盖度"}).then(res => {
            this.bussinessUnit = res.data.data
            this.bussinessUnit = excludeHiddenBussinessUnit(this.bussinessUnit)
            this.select = this.bussinessUnit[0]
            if (this.fromPage != 'creater') {
              this.searchForm.trgNode = this.bussinessCode
              let selectData = this.bussinessUnit.find(item => item.trgNode == this.searchForm.trgNode)
              if (selectData) {
                coverApi.getRptTrgnodeTree({parentNodeCode: selectData.nodeId}).then(second => {
                  this.secondOrgan = second.data.data
                })
              }
            }
            // this.searchForm.trgNode = this.bussinessUnit[0].nodeName
            this.loadInit = true
            this.$nextTick(() => {
              this.searchValueSet()
            })

          })
      } else {
          var newData = coverData.data.filter(function (res) {
            return res.value !== '华润医药集团有限公司'
          })
          this.bussinessUnit = newData
          if (this.fromPage != 'creater') {
            this.searchForm.trgNode = this.bussinessCode
            let selectData = this.bussinessUnit.find(item => item.vsiValue == this.searchForm.trgNode)
            this.secondOrgan = selectData ? selectData.children : []
          }

          this.select = this.bussinessUnit[0]
          this.loadInit = true

           this.$nextTick(() => {
              this.searchValueSet()
            })
      }

    },
    //二级组织
    changetrgNode(item) {
      if (this.useApiGetData) {
       coverApi.getRptTrgnodeTree({parentNodeCode: item.nodeId}).then(second => {
          this.secondOrgan = second.data.data
        })
      } else {
      // 更换业务单元获取方式
        this.secondOrgan = item.children
        this.searchForm.company = ''
      }

    },

    //获取列表
    getListPage({ responseProcess, param }) {
      let { pageNum, pageSize, id, trgNode, operateStatus, reportCycle, allDataFlag, self} = param
      let paramsData = {
        taskCode: id,//:"编码",
        trgNode: trgNode,// "业务单元",
        operateStatus: operateStatus,
        reportCycle: reportCycle, // 填报周期、目标年度
        allDataFlag: allDataFlag, // 数值范围
        rptType: this.rptType,
        currentPage: pageNum, //-----当前页码
        pageSize: pageSize //-----每页条数
      }
      return coverApi.getwfRptDgCalList2({
        data: paramsData,
        type: param.fromPage
      }).then(res => {
        if(res.data.code == 200) {
          let data = res.data
          let { current, records, size, total } = data.data
          if(records && records.length) {
            records.forEach(element => {
              element.operateStatusName = PROCESS_STATUS_MAP[element.operateStatus]
            });
          }
          responseProcess({
            pageNum: Number(current),
            pageSize: Number(size),
            records: records || [],
            total: Number(total)
          })
        } else {
          self.$Message.error({
            content: res.data.msg || '操作失败',
            duration: 3
          })
        }
        self.ids = []
      })
    },
    goDetail(row) {
      let tableNames = {
        rate: '计算表',
        status: '现状表',
        target: '目标表'
      }
      new this.$sidelipPage(
          coverDetail,
          {
            props: {
              title: row.trgNode + '关键业务环节数字化覆盖度' + '_'+ tableNames[this.type] + '_' + (row.reportCycle || ''),
              id: row.id,
              tableType: this.type,
              trgNode: row.trgNode,
              reportCycle: row.reportCycle,
              bindId: row.bindId,
              rptType: row.rptType,
            }
          },
          data => {
            data && this.searchValueSet()
          }
        )
      // 跳转详情
      // if (this.type == 'rate') {
      //   new this.$sidelipPage(
      //     CoverRateEdit,
      //     {
      //       props: {
      //         title: this.title + '详情',
      //         id: row.id,
      //         disabledPage: true,
      //         vsCode: this.vsCode,
      //         Code: this.searchForm.trgNode,
      //         dataStatus: Number(row.operateStatus) || 3,
      //         fromPage: this.fromPage
      //       }
      //     },
      //     data => {
      //       data && this.searchValueSet()
      //     }
      //   )
      // } else {
      //  if (this.type == 'status') {
      //   new this.$sidelipPage(
      //       coverDetail,
      //       {
      //         props: {
      //           title: row.trgNode + '关键业务环节数字化覆盖度' + '_'+ tableNames[this.type] + '_' + (row.reportCycle || ''),
      //           id: row.id,
      //           tableType: this.type,
      //           trgNode: row.trgNode,
      //           reportCycle: row.reportCycle,
      //           bindId: row.bindId,
      //         }
      //       },
      //       data => {
      //         data && this.searchValueSet()
      //       }
      //     )
      //   } else {
      //     new this.$sidelipPage(CoverTargetEdit, {
      //       props: {
      //         title: this.title + '详情',
      //         id: row.id,
      //         disabledPage: true,
      //         type: this.type,
      //         vsCode: this.vsCode,
      //         Code: this.searchForm.tableCode,
      //         dataStatus: Number(row.wfStatus) || 3,
      //         fromPage: this.fromPage
      //       }
      //     })
      //   }
      // }
    },
    goEdit(row) {
      this.$refs.modifyForm.resetFields()
      this.modifyForm.row = row
      this.modifyForm.trgNode = row.trgNode
      this.modifyForm.reportCycle = row.reportCycle
      this.modifyForm.file = ''
      this.modifyForm.fileData = undefined
      this.modifyDisplay = true
    },
    // 导入成功回调
    uploadSuccess() {
      this.searchValueSet()
    },
    downloadTemplate(trgNode = null) {
      const link = document.createElement('a')
      link.style.display = 'none'
      link.href = trgNode ? `${this.downloadUrl}?TrgNode=${trgNode}` : this.downloadUrl
      link.setAttribute('download', 'fillname')
      document.body.appendChild(link)
      link.click()
      link.remove()
    },
    //搜索
    searchValueSet(pageNum = null) {
      this.$refs['coverTable'].load(this.searchForm, pageNum)
    },
    add() {
      // 跳转新增页面
      if (this.type == 'rate') {
        new this.$sidelipPage(
          CoverRateEdit,
          {
            props: {
              title: this.title + '新建',
              vsCode: this.vsCode,
              Code: ''
            }
          },
          data => {
            data && this.searchValueSet()
          }
        )
      } else {
        new this.$sidelipPage(
          CoverTargetEdit,
          {
            props: {
              title: this.title + '新建',
              type: this.type,
              vsCode: this.vsCode,
              Code: ''
            }
          },
          data => {
            data && this.searchValueSet()
          }
        )
      }
    },
    // 批量提交
    commitFun(ids, api, batch = true) {
      let text = '是否要提交?'
      if (this.type == 'status') {
        text = '存在同填报周期计算表尚未提交，本次提交将同时提交计算表，您确定要提交吗？'
      } else if (this.type == 'rate') {
        text = '存在同填报周期现状表尚未提交，本次提交将同时提交现状表，您确定要提交吗？'
      }
      this.$confirm({
        title:"提交",
        content: batch ? "是否要批量提交?" : text
      }).then(()=>{
        api(
          {
            data: ids
          }
        ).then((result) => {
            if(result.data.code == 200){
              this.$Message.success({
                content: '提交成功',
                duration: 3
            })
          } else {
              this.$Message.error({
                content: result.data.msg || '提交失败',
                duration: 3
            })
          }
          this.searchValueSet()
        })
      })
    },
    onSelectionChange(selection) {
        this.ids = []
         selection.forEach(element => {
          this.ids.push({id: element.id, operateStatus: element.operateStatus, trgNode: element.trgNode})
         });
    },
    getUrl(type, pathname) {
      return window.RPConfig[type] + pathname;
    },
    // 批量删除
    batchDel () {
      if(this.ids.length === 0) {
        this.$Message.error({
          content: '请选择数据后再进行操作',
          duration: 3
        })
        return
      }
      const ids = []
      this.ids.forEach(item => {
        // 状态为1(待提交)时可以删除
        if(item.operateStatus == 1 && this.ids.filter(e => e.operateStatus == 1).length === this.ids.length) {
          ids.push(item.id)
        }
      })
      if(ids.length > 0) {
        this.deleteFun(ids)
      } else {
        this.$Message.error({
          content: '仅状态为待提交的数据可以删除，请重试',
          duration: 3
        })
      }
    },
    // 批量提交
    batchSubmit() {
      if(this.ids.length === 0) {
        this.$Message.error({
          content: '请选择数据后再进行操作',
          duration: 3
        })
        return
      }
      const ids = []
      this.ids.forEach(item => {
        // 状态为1提交
        if(item.operateStatus == 1 && this.ids.filter(e => e.operateStatus == 1).length === this.ids.length) {
          ids.push(item.id)
        }
      })
      if(ids.length > 0) {
        this.commitFun(ids, coverApi.coverCommit2)
      } else {
        this.$Message.error({
          content: '仅状态为待提交的数据可以提交，请重试',
          duration: 3
        })
      }
    },
    submitFun(row) {
      // 提交
      const ids = [row.id]
      this.commitFun(ids, coverApi.coverCommit2, false)
    },
    handleUpload(file) {
      if (this.checkImportFile(file)) {
        this.importForm.fileData = file
        this.importForm.file = file.name
      }
      return false;
    },
    handleImportFun() {
      this.$refs.importForm.validate((valid) => {
        if (valid) {
          this.importFile(this.url('itShare', '/rptDgcalOperate/excelImport/common'), this.importForm.fileData, {reportCycle: this.importForm.reportCycle, rptType: this.rptType, trgNode: this.importForm.trgNode}).then((res) => {
            if (res.code === 200) {
              this.importDisplay = false
              this.$refs.importForm.resetFields()
              this.searchValueSet(1)
              this.$Message.success({
                content: '导入成功',
                duration: 3
              })
            } else {
              this.$Message.error({
                content: res.msg,
                duration: 3
              })
            }
            this.importLoadding = false
            this.$nextTick(() => {
              this.importLoadding = true
            })
          }).catch(e => {
            this.importLoadding = false
            this.$nextTick(() => {
              this.importLoadding = true
            })
            this.$Message.error({
              content: e,
              duration: 3
            })
          })
          
        } else {
          this.importLoadding = false
          this.$nextTick(() => {
            this.importLoadding = true
          })
        }
      })
    },
    showImport() {
      this.$refs.importForm.resetFields()
      if (this.type === 'target') {
        const date = new Date()
        this.importForm.reportCycle = `${date.getFullYear()}`;
      }
      this.importDisplay = true
    },
    handleModifyUpload(file) {
      if (this.checkImportFile(file)) {
        this.modifyForm.fileData = file
        this.modifyForm.file = file.name
      }
      return false
    },
    handleModifyFun() {
      this.$refs.modifyForm.validate((valid) => {
        if (valid) {
          this.importFile(this.url('itShare', '/rptDgcalOperate/batch/update'), this.modifyForm.fileData, {operateId: this.modifyForm.row.id}).then((res) => {
            if (res.code === 200) {
              this.modifyDisplay = false
              this.$refs.modifyForm.resetFields()
              this.searchValueSet(1)
              this.$Message.success({
                content: '修改成功',
                duration: 3
              })
            } else {
              this.$Message.error({
                content: res.msg,
                duration: 3
              })
            }
            this.modifyLoadding = false
            this.$nextTick(() => {
              this.modifyLoadding = true
            })
          }).catch(e => {
            this.modifyLoadding = false
            this.$nextTick(() => {
              this.modifyLoadding = true
            })
            this.$Message.error({
              content: e,
              duration: 3
            })
          })
        } else {
          this.modifyLoadding = false
          this.$nextTick(() => {
            this.modifyLoadding = true
          })
        }
      })
    },
    importFile(url, file, params) {
      return coverApi.importFile({url: url, file: file, params: params})
    },
    checkImportFile(file) {
      // 文件类型控制
      const fileType = file.type
      if (
        fileType !== 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' &&
        fileType !== 'application/vnd.ms-excel'
      ) {
        this.$Message.error({
          content: '仅支持.xls .xlsx格式文件',
          duration: 3
        })
        return false
      }
      return true
    }
  },
  created() {
    // this.getLevelList()
  },
  // mounted() {
  //   this.getData()
  // }
}
</script>

<style lang="less">
.modify-modal {
  .download-btn {
      position: absolute;
      top: 2px;
      left: 140px;
    }
}
</style>>

<style lang="less" scoped>
/deep/.table-bar button:last-child {
  color: #ffffff;
  background-color: #ff6f4b;
  border-color: #ff6f4b;
}

</style>
